{include file="common/header"}
<!-- 编辑器 -->
<script charset="utf-8" src="/admin_static/library/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/admin_static/library/kindeditor/lang/zh-CN.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="/admin_static/css/plugins/webuploader/webuploader.css">
<link rel="stylesheet" type="text/css" href="/admin_static/css/demo/webuploader-demo.min.css"> -->

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                   <div class="ibox-title">
                        <h5>商品分类编辑</h5>
                        <span class="label label-primary pull-right label-primary-cust">
                            <a href="javascript:self.location=document.referrer;" class="fa-lg-cust-a" title="返回上一页">
                                <i class="fa fa-arrow-left fa-lg-cust"  aria-hidden="true"></i>
                            </a>
                        </span>
                    </div>
                    <div class="ibox-content">
                        <div class="alert alert-danger">
                            <b>警告：</b>分类图必须是96*96的大小
                        </div>
                        <form class="form-horizontal m-t" id="partner" enctype="multipart/form-data">
                            <input type="hidden" name="type_id" value="<?php echo $_GET['type_id'] ?>">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">分类名称：</label>
                                <div class="col-sm-8">
                                    <input name="type_name" type="text" value="<?php echo $res['type_name']; ?>" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">分类排序：</label>
                                <div class="col-sm-8">
                                    <input name="seq" onkeyup="value=value.replace(/[^\d]/g,'')" type="number" class="form-control" required="" value="<?php echo $res['seq']; ?>" placeholder="1~99 数字越小越靠前，首页显示前6个分类,可不填" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">封&nbsp;&nbsp;面&nbsp;&nbsp;图：</label>
                                <div class="col-sm-8">
                                    <img style="width:96px;height:96px;" src="<?php echo $res['type_img']; ?>" alt="">
                                    <input type="file" name="type_img" class="form-control" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group form-group-bottom">
                                <div class="col-sm-2 col-sm-offset-3">
                                    <p class="btn btn-primary" onclick="submitAdd();">确定修改</p>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            
            </div>
           
        </div>
    </div>
</body>
{include file="common/footer"}
<script>

    //按钮样式
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});

    function submitAdd(){
        var formData = new FormData($('#partner')[0]);
        $.ajax({
            url: "/Admin/goods/type_edit",
            data:formData,
            type: "POST",
            dataType:'json',
            cache: false,//上传文件无需缓存
            processData: false,//用于对data参数进行序列化处理 这里必须false
            contentType: false, //必须
            success: function (d) {
                if(d){
                    if(d.error){
                        swal(d.msg, "", "error");
                        return false;
                }else{
                        swal(d.msg, "", "success");
                        setTimeout("window.location.href = '/admin/goods/type_list';",1000);
                    }
                }
            }
        })

    }
</script>
